package br.unipar.bancodedados.manager;

import java.sql.Connection;
import java.sql.DriverManager;

public abstract class ConnectionSingleton {

    private static Connection connection;

    public static Connection getInstance() {
        if (connection == null) {
            System.out.println("CRIANDO UMA CONEXAO.");
            try {
                String driver = "com.mysql.jdbc.Driver";
                String url = "jdbc:mysql://localhost:3306/unipar";
                String user = "root";
                String senha = "teste";

                // SINGLETON
                Class.forName(driver);
                connection = DriverManager.getConnection(url, user, senha);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return connection;
    }

    private ConnectionSingleton() {

    }


}
